package com.xnck.example.jertest.util;


import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class BeanUtil implements ApplicationContextAware {

    public static ApplicationContext context;

    public void setApplicationContext(ApplicationContext context)
            throws BeansException {
        BeanUtil.context = context;
    }

    public static <T> T getBean(String beanId, Class<T> clazz){
        return context.getBean(beanId, clazz);
    }

    public static ApplicationContext getContext(){
        return context;
    }

}

